package whf.framework.web.tag;

import java.util.ArrayList;
import java.util.List;

import whf.framework.datasource.DataRow;
import whf.framework.datasource.DataSource;
import whf.framework.meta.entity.IMeta;

public class TableModel {
	private DataSource<DataRow> dataSource;

	private List<TableColumn> columns = new ArrayList<TableColumn>();
	
	private List<TableRow> rows = new ArrayList<TableRow>();

	private String id;
	
	private String caption;
	
	private String footer;
	
	private IMeta meta;

	public TableModel(DataSource<DataRow> dataSource, IMeta meta) {
		this.meta = meta;
		this.dataSource = dataSource;
	}
	
	public DataSource<DataRow> getDataSource() {
		return this.dataSource;
	}

	public void addRow(TableRow row) {
		this.rows.add(row);
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public List<TableRow> getRows() {
		return rows;
	}

	public void setRows(List<TableRow> rows) {
		this.rows = rows;
	}
	
	public void setCaption(String caption){
		this.caption = caption;
	}
	
	public String getCaption(){
		return this.caption;
	}
	
	public boolean isEmpty(){
		return this.rows.isEmpty();
	}

	public List<TableColumn> getColumns() {
		return columns;
	}

	public void setColumns(List<TableColumn> columns) {
		this.columns = columns;
	}
	
	public void addColumn(TableColumn col){
		this.columns.add(col);
	}
	
	public void clearUp(){
		this.columns.clear();
	}

	public String getFooter() {
		return footer;
	}

	public void setFooter(String footer) {
		this.footer = footer;
	}
	
	public IMeta getMeta(){
		return this.meta;
	}
}
